#ifndef NctiWindowViewManager_H
#define NctiWindowViewManager_H
#include "ncti.h"

#include "ncti_dcl_window.h"
#include "NctiWindowObject.h"

namespace NCTI
{
	class NctiBaseView;
	class NctiWindowView;
	class NctiDocument;
	class NctiWindowObject;
	/**
	* @brief manager oneself window view
	* @see NctiUserInterfaceManager
	*/
	class DECL_NCTI_WINDOW NctiWindowViewManager : public NctiWindowObject
	{
	public:
		virtual ~NctiWindowViewManager();
		/**
	   * @brief create a view manager
	   * @param[in] i_docid, the Document ID
	   * @param[in] i_parent, NctiWindowPlatform
	   * @param[in] i_name, the title
	   * @return NctiWindowViewManager
	   */
        static NctiWindowViewManager* CreateViewMgr(Ncti_UInteger i_docId, NctiWindowObject* i_parent = nullptr,const std::string& i_name = "Main");
		/**
	   * @brief get a view manager by Document ID
	   * @param[in] i_docid, the Document ID
	   * @return NctiWindowViewManager
	   */
        static NctiWindowViewManager* GetViewMgr(Ncti_UInteger i_docId);
		/**
	   * @brief remove a view manager by Document ID
	   * @param[in] i_docid, the Document ID
	   */
        static void RemoveViewMgr(Ncti_UInteger i_docId);
		/**
	   * @brief refresh the window
	   */
        void Redraw();

		/**
	   * @brief implement the resize function event
	   * @param[in] i_event, NctiWindowResizeEvent
	   */
        void resizeEvent(NctiWindowResizeEvent* i_event)override;
		/**
	   * @brief create base view by name
	   * @param[in] i_name
	   * @param[in] I_enMeshDisp
	   * @return Ncti_Integer
	   */
		Ncti_Integer CreateBaseView(const char* i_name,Ncti_Boolean i_enMeshDisp = true);
		/**
	   * @brief create window view
	   * @param[in] i_baseViewId
	   * @param[in] i_RenderModelType
       * @param[in] i_show show the window
	   * @return Ncti_Boolean
	   */
		Ncti_Boolean CreateWindowView(Ncti_Integer i_baseViewId, EnumRenderModelType i_RenderModelType);
		/**
	   * @brief activate window by NctiWindowView
	   * @param[in] i_win
	   * @param[in] i_activeBaseview
	   */
		void OnActivateWindow(NctiWindowView* i_win, Ncti_Boolean i_active);
		/**
	   * @brief activate window by NctiWindowView index
	   * @param[in] i_win
	   * @param[in] i_activeBaseview
	   */
		void OnActivateView(Ncti_Integer i_ViewId, Ncti_Boolean i_active);
		/**
	   * @brief get all NctiWindowViews
	   * @return  std::vector<NctiWindowView*>
	   */
		std::vector<NctiWindowView*> GetViewVec();

		/**
	   * @brief SetViewVisible
	   * @param[in] i_viewId
	   * @param[in] i_show show or hide
	   */
		void SetViewVisible(Ncti_Boolean i_show, Ncti_Integer i_viewId = -1);

		/**
	   * @brief get main window view by NctiWindowView index
	   * @param[in] i_viewId
	   */
		NctiWindowView* GetMainView(Ncti_Integer i_viewId = -1);
		/**
	   * @brief get main base view by NctiWindowView index
	   * @param[in] i_viewId
	   */
		NctiBaseView* GetMainBaseView(Ncti_Integer i_viewId = -1);
		/**
	   * @brief get document of this
	   * @return NctiDocument
	   */
		NctiDocument* GetDocument();
	private:
		/**
	   * @brief internal used
	   */
		void InitControlPosition(Ncti_Integer i_w, Ncti_Integer i_h);
        NctiWindowViewManager(Ncti_Integer id, NctiWindowObject* parent);
	private:
		Ncti_Integer m_curView = 0;
        std::vector<std::pair<NctiBaseView*,NctiWindowView*>> m_ViewVec;
		Ncti_Integer m_docId{-1};
	};

}
#endif
